package net.csdn.business.notify.handler.handler.impl;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import net.csdn.business.notify.common.enums.NotifyChannel;
import net.csdn.business.notify.common.pipeline.domain.TaskInfo;
import net.csdn.business.notify.common.pipeline.model.SmsContentModel;
import net.csdn.business.notify.handler.handler.BaseHandler;
import org.springframework.stereotype.Component;



/**
 * @ClassName SmsHandler
 * @Description 短信发送处理
 * @Author zhangyl
 * @Date 2023/11/30 18:29
 */
@Component
@Slf4j
public class SmsHandler extends BaseHandler{

    public SmsHandler() {
        channelCode = NotifyChannel.SMS.getCode();
    }

    @Override
    public boolean handler(TaskInfo taskInfo) {
        return false;
    }




    /**
     * 如果有输入链接，则把链接拼在文案后
     * <p>
     * PS: 这里可以考虑将链接 转 短链
     * PS: 如果是营销类的短信，需考虑拼接 回TD退订 之类的文案
     */
    private String getSmsContent(TaskInfo taskInfo) {
        String contenModel= taskInfo.getContentModel();
        SmsContentModel smsContentModel = JSONObject.parseObject(contenModel,SmsContentModel.class);
        if (StrUtil.isNotBlank(smsContentModel.getUrl())) {
            return smsContentModel.getContent() + StrUtil.SPACE + smsContentModel.getUrl();
        } else {
            return smsContentModel.getContent();
        }
    }

}
